home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 6.6 KB | 217 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1993-1997
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: LQCustom.lib
- #
- # Version: 2.1.4
- # Description:
- # A library to introduce custom activities in between launch and quit.
- # Contains:
- # LQCustomTask()
- # unexpected_window()
- #
- # History:
- # Date: By: Changes:
- # 08/09/93 SBR Created
- # 08/05/95 SBR Added Apple Copyright header for Radar 1273925
- # 09/27/96 BRL Added SPEC Exception handling
- # 01/21/97 SBR Deleted older exception code and comments.
- #
- #########################################################################
- #########################################################################
- Libraries
- "Additions.lib",
- "Clouseau.lib",
- "LaunchQuits.lib",
- "Report.lib",
- "VUAid.lib",
- "ExceptionHandling.lib",
- "AutoDialogAIQ New";
-
- #########################################################################
- # task LQCustomTask()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: The LaunchQuit engine calls this task after completing the launch,
- # before beginning the quit. This task can call other tasks, but it must
- # leave the application in the same state as when it was called, so
- # the quit will still work.
- # Parameters: none -- to make it easy on the engine
- # Returns: true: everything worked
- # false: something did not work
- # Examples: see checkLaunchQuit() in LaunchQuits.lib
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 08/09/93 SBR Created
- # 03/22/94 SBR Now returns true or false.
- # 09/27/96 BRL Added SPEC Exception handling
- #########################################################################
- task LQCustomTask()
- begin
- ### Collect all menuItems that end in '…' or '...'
-
- DialogMenuItemList := _Collect([menuItem t:/≈.../ e:true ]) + _Collect([menuItem t:/≈…/ e:true ]);
-
- println " Collected all menu items ending in '...' and '…'";
-
- topWindow := _Match([window o:1], true);
-
- for each dialogMenuItem in DialogMenuItemList
- begin
- println;
- theContainer := dialogMenuItem.m;
- if descType(theContainer) = 'menuItem'
- begin
- try
- match [menuItem t:theContainer.t o:theContainer.o m:[menu t:?mT o:?mO]]!;
- catch theError
- exceptionDispatcher(theError,,{"LQCustomTask()", {[menuItem t:theContainer.t o:theContainer.o m:[menu t:?mT o:?mO]]}});
-
- _Select([menuItem t:dialogMenuItem.t m:[menuItem t:theContainer.t o:theContainer.o m:[menu t:mT o:mO]]], true);
-
- println " selected ", [menuItem t:dialogMenuItem.t m:
- [menuItem t:theContainer.t o:theContainer.o m:[menu t:mT o:mO]]]!;
- end;
- else
- begin
- _Select(dialogMenuItem);
- println " selected ", dialogMenuItem;
- end;
-
- wait(2);
- unexpected_window('window', {topWindow});
- end;
-
- AutoDialog();
- return true;
- end;
-
-
- ############################################################################
- #
- #
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??/??/?? ??? Created
- # 09/27/96 BRL Added SPEC Exception handling
- #########################################################################
- task unexpected_window(expectedItem := "", expectedDesc := {[]})
- begin
- try
- match[target t:?tName];
- catch theError
- ExceptionDispatcher(theError,,{"Match 1 in unexpected_window", {expectedItem, expectedDesc}});
-
- if expectedItem = "window" #the current window may be the expected!
- begin
- if _Match(expectedDesc[1], true)
- return false;
- end;
-
- try
- topWind := match[window o:1 t:?windTitle s:?windStyle k:?kList r:?windRect];
- catch theError
- ExceptionDispatcher(theError,,{"Match 2 in unexpected_window", {expectedItem, expectedDesc}});
-
- if not topWind #no dialog
- return false;
-
- (*Collect the staticText items*)
- staticList := kList;
- for i := card staticList to 1 step -1 begin
- if (descType(staticList[i]) <> 'staticText')
- staticList := remove(i, staticList);
- end;
- if card staticList = 1 temp := "only staticText string is: " + staticList[1].t;
- else if card staticList = 0 temp := "no staticText strings present";
- else temp := "multiple staticText strings, one is: " + staticList[1].t;
-
- println(" {windStyle} window titled '{windTitle}'; {temp}");
-
- (*Try the escape key*)
- type_keys({escapeKey});
- println(" pressed the escape key");
- if await_absence(topWind,2,,,6)
- return true;
-
- (*Try the Cancel button*)
- cancelButton := _Match([button t:'Cancel' w:1], true); ## exact match
-
- if cancelButton
- begin
- _Select(cancelButton, true); ## exact selection
-
- println(" selected the Cancel button");
- if await_absence(topWind,2,,,6)
- return true;
- end;
-
- (*Put button titles into a list*)
- buttonList := {};
- for i := 1 to card kList begin
- thisContentItem := kList[i];
- if thisContentItem.e and (descType(thisContentItem) = 'button')
- buttonList := buttonList + {thisContentItem.t};
- end;
-
- (*If there is just one enabled button, select it*)
- if (card buttonList = 1) begin
- temp := buttonList[1];
- if not (temp ~= /≈launch≈/) begin
-
- _Select([button t:temp w:1], true); ## exact selection
-
- println(" unexpected_window: selected only enabled button {temp}");
- end;
- end;
- if await_absence(topWind,2,,,6)
- return true;
-
- (*If there are no enabled buttons, signal a warning*)
- else if (card buttonList < 1) begin
- CenterOfWindowClick();
- println(" clicked in the center of the window");
- if await_absence(topWind,2,,,6)
- return true;
- else begin
- println(" no way out -- need human intervention");
- RStatus("{tName} IS STUCK IN A DIALOG! PLEASE DISMISS IT TO CONTINUE THE SCRIPT…",1);
- while not await_absence(topWind,60,,,6)
- SysBeep();
- return true;
- end;
- end;
- else for each goodTry in {'Cancel','Done','OK','No','Yes'} begin
- if isMember(goodTry, buttonList) begin
-
- _Select([button t:goodTry w:1], true); ## exact selection
-
- println(" selected button named {goodTry}");
- if await_absence(topWind,2,,,6)
- return true;
- end;
- end;
- println(" unexpected_window: {buttonList}");
- for i := 1 to card buttonList begin
- if buttonList[i].t <> ''
- begin
- if _MatchBoolean(buttonList[i], true)
- begin
- temp := buttonList[i].t;
-
- _Select([button t:temp]);
-
- if _MatchBoolean([window s:dialog o:1], true) or _MatchBoolean([window s:movablemodal o:1], true)
- unexpected_window();
- end;
-
- if not (_MatchBoolean([window s:dialog o:1], true) or _MatchBoolean([window s:movablemodal o:1], true))
- i := card buttonList;
- end;
- end;
- end;
-